﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ControllerStudy.Controllers
{
    public class CalculatorController : Controller
    {
        //
        // GET: /Calculator/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Calculate(double a, double b, string o)
        {
            if (o == "+")
            {
                double c = a + b;
                ViewBag.KetQua = c;
            }
            else if (o == "-")
            {
                double c = a - b;
                ViewBag.KetQua = c;
            }
            else if (o == "x")
            {
                double c = a * b;
                ViewBag.KetQua = c;
            }
            else if (o == ":")
            {
                double c = a / b;
                ViewBag.KetQua = c;
            }
            else
            {
                ViewBag.KetQua = "Không hiểu";
            }
            return View("Index");
        }
	}
}